<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <!-- 解决图片跨域问题 -->
    <meta name="referrer" content="no-referrer" />
    <link rel="icon" href="https://www.21cake.com/favicon.ico">
    <title>21Cake蛋糕官网_24小时蛋糕网上订购_5小时新鲜送达！</title>
    <link rel="stylesheet" href="../css/reset.css">
    <link rel="stylesheet" href="../css/iconfont/iconfont.css">
    <link rel="stylesheet" href="./css/cakeheader.css">
    <script src="../js/jquery-1.9.1.min.js"></script>

</head>

<body>

    <!-- 城市切换 -->
    <div class="zfg-cutover">
        <span>欢迎来到21cake官网商城</span>
        <img data-src="https://static.21cake.com//themes/site/img/logo-di.png" alt="">
        <div class="zfg-cutover-ul">
            <p>请选择您的配送城市：上海市</p>
            <ul class="cutover-ul">
                <li class="zfg-active">上海</li>
                <li>北京</li>
                <li>天津</li>
                <li>杭州</li>
                <li>无锡</li>
                <li>苏州</li>
                <li>广州</li>
                <li>深圳</li>
            </ul>
        </div>
    </div>
    <div class="zfg-bigdiv">
        <div class="zfg-small">
            <span>正在切换城市加载，请稍后....</span>
        </div>
    </div>
    <!-- 公共头部 -->
    <div class="zfg_header">
        <!-- 公共头部导航 -->
        <div class="zfg_header_nav">
            <div class="zfg_header_navlogo">
                <img data-src="https://static.21cake.com/themes/site/img/logo.png" alt="21cake logo">
            </div>
            <!-- 导航左 -->
            <ul class="zfg_nav-left">
                <li><a href="javascript:;" class="zfg_nav-left1">首页</a></li>
                <li><a href="javascript:;" class="zfg_nav-left2">蛋糕</a></li>
                <li><a href="javascript:;" class="zfg_nav-left3">面包</a></li>
                <li><a href="javascript:;" class="zfg_nav-left4">冰淇淋</a></li>
                <li><a href="javascript:;" class="zfg_nav-left5">咖啡下午茶</a></li>
                <li><a href="javascript:;" class="zfg_nav-left6">全国送</a></li>
                <li><a href="javascript:;" class="zfg_nav-left7">企业专区</a></li>
            </ul>
            <div class="zfg_nav-right">
                <ul>
                    <li class="zfg-cade-app">
                        <b>APP下载</b>
                        <div class="APPer">
                            <img data-src="https://static.21cake.com/themes/site/img/footer-erweima.png" alt="">
                            <span>下载享更多优惠</span>
                        </div>
                    </li>
                    <li class="zfg-cade-ul"><b>上海</b><i></i>
                        <ul class="zfg-cade-ul-er">
                            <li>上海</li>
                            <li>北京</li>
                            <li>天津</li>
                            <li>杭州</li>
                            <li>无锡</li>
                            <li>苏州</li>
                            <li>广州</li>
                            <li>深圳</li>
                        </ul>
                    </li>
                    <li class="zfg-cade-xiaoxi"><b>消息</b>
                        <ul class="zfg-cade-xiaoxi-er">
                            <li>通知</li>
                            <li>物流</li>
                        </ul>
                    </li>
                    <li class="zfg-cade-login">
                        <!--                         
                        <b>登录</b><b>/注册</b> -->
                        <!-- <img data-src="https://static.21cake.com/themes/site/img/user-img.png" alt="">
                        <ul class="zfg-cade-login-er">
                            <li>我的订单</li>
                            <li>我的优惠券</li>
                            <li>我的纪念日</li>
                            <li>退出登录</li>
                        </ul> -->
                    </li>
                    <li class="zfg-cade-car">
                        <!-- <i></i>
                        <span></span> -->
                    </li>
                </ul>
            </div>
        </div>

    </div>
</body>
<script>
    if (localStorage.getItem('position')) {
        $('.zfg-cade-ul>b').html(localStorage.getItem('position'))
        $('.zfg-cutover').css('display', 'none')
    } else {
        $('.zfg-cutover').css('display', 'block')
        $('.cutover-ul>li').click((e) => {
            localStorage.setItem('position', e.target.innerText)
            window.history.go(0)
        })

    }
    // console.log($('.zfg-cade-ul-er>li'));
    $('.zfg-cade-ul-er>li').click((e) => {

        localStorage.setItem('position', e.target.innerText)
        $('.zfg-bigdiv').css({
            display: "block"
        })
        setTimeout(() => {
            window.history.go(0)
        }, 1000)
    })
    if (localStorage.getItem('token')) {
        $('.zfg-cade-login').html(` <img data-src="https://static.21cake.com/themes/site/img/user-img.png" alt="">
                        <ul class="zfg-cade-login-er">
                            <li class="wode">我的订单</li>
                            <li>我的优惠券</li>
                            <li>我的纪念日</li>
                            <li>退出登录</li>
                        </ul>`)

    } else {

        $('.zfg-cade-login').html(`<b>登录</b><b>/注册</b>`)
    }



    // if (localStorage.getItem('jsonArrlength')) {
    //     $('.zfg-cade-car').html(`<i></i>
    //                     <span></span>`)
    //     $('.zfg-cade-car span').html(localStorage.getItem('jsonArrlength'))
    // } else {
    //     $('.zfg-cade-car').html(`<i></i>`)
    // }
    if (localStorage.getItem("cakeArr")) {
        $('.zfg-cade-car').html(`<i></i>
                        <span></span>`)
        $('.zfg-cade-car span').html(JSON.parse(localStorage.getItem("cakeArr")).length)
    } else {
        $('.zfg-cade-car').html(`<i></i>`)
    }

    // if (localStorage.getItem('hjlallarrlength')) {
    //     $('.zfg-cade-car').html(`<i></i>
    //                     <span></span>`)
    //     $('.zfg-cade-car span').html(localStorage.getItem('hjlallarrlength'))
    // } else {

    //     $('.zfg-cade-car').html(`<i></i>`)
    // }

    if (window.location.href.indexOf("index.html") + 1) {
        $('.zfg-cade-xiaoxi-er>li').click((e) => {
            window.location.href = "./page/login.html"
        })
        $('.zfg-cade-login>b:first-child').click((e) => {
            window.location.href = "./page/login.html"
        })
        $('.zfg-cade-login>b:last-child').click((e) => {
            window.location.href = "./page/register.html"
        })
        $('.zfg-cade-car>i').click((e) => {
            window.location.href = "./page/cake_Car.html"
        })
        $('.zfg_nav-left1').click((e) => {
            window.location.href = "./index.html"
        })
        $('.zfg_nav-left2').click((e) => {
            window.location.href = "./page/list.html"
        })
        $('.zfg_nav-left3').click((e) => {
            window.location.href = "./page/list.html"
        })
        $('.zfg_nav-left4').click((e) => {
            window.location.href = "./page/list.html"
        })
        $('.zfg_nav-left5').click((e) => {
            window.location.href = "./page/list.html"
        })
        $('.zfg_nav-left6').click((e) => {
            window.location.href = "./page/list.html"
        })
        $('.zfg_nav-left7').click((e) => {
            window.location.href = "./page/list.html"
        })
        $('.wode').click((e) => {
            window.location.href = "./page/me.html"
        })
        $('.zfg-cade-login-er>li:last-child').click((e) => {
            localStorage.removeItem('token')
            window.location.href = "./index.html"
            window.history.go(0)
        })

    } else {

        $('.zfg-cade-xiaoxi-er>li').click((e) => {
            window.location.href = "../page/login.html"
        })
        $('.zfg-cade-login>b:first-child').click((e) => {
            window.location.href = "../page/login.html"
        })
        $('.zfg-cade-login>b:last-child').click((e) => {
            window.location.href = "../page/register.html"
        })
        $('.zfg-cade-car>i').click((e) => {
            window.location.href = "../page/cake_Car.html"
        })
        $('.zfg_nav-left1').click((e) => {
            window.location.href = "../index.html"
        })
        $('.zfg_nav-left2').click((e) => {
            window.location.href = "../page/list.html"
        })
        $('.zfg_nav-left3').click((e) => {
            window.location.href = "../page/list.html"
        })
        $('.zfg_nav-left4').click((e) => {
            window.location.href = "../page/list.html"
        })
        $('.zfg_nav-left5').click((e) => {
            window.location.href = "../page/list.html"
        })
        $('.zfg_nav-left6').click((e) => {
            window.location.href = "../page/list.html"
        })
        $('.zfg_nav-left7').click((e) => {
            window.location.href = "../page/list.html"
        })
        $('.wode').click((e) => {
            window.location.href = "../page/me.html"
        })
        $('.zfg-cade-login-er>li:last-child').click((e) => {
            localStorage.removeItem('token')
            localStorage.removeItem('username')
            if (window.location.href = "../page/me.html") {
                window.location.href = "./index.html"
            }

            window.history.go(0)
        })
    }
</script>
<script>
    // 懒加载
    window.onload = loadImg;
    window.onscroll = scrollImg(loadImg);

    function loadImg() {
        let img = document.querySelectorAll("img");
        img.forEach((item, index) => {
            if (item.getBoundingClientRect().top < window.innerHeight) {
                item.src = item.dataset.src;
                // console.log(item.dataset.src);
            }
        });
    }

    function scrollImg(attr) {
        // console.log(111);
        let timer = null;
        let content = this;

        return function () {
            clearTimeout(timer);
            timer = setTimeout(() => {
                attr.call(content);
            }, 300);
        };
    }
</script>

</html>